{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
    <h3 class="pb-3">添加信息</h3>
    {if condition="($id == 0)"}
    <table class="layui-table layui-table-form">
        <tr>
            <td colspan="6"><strong>打款信息</strong></td>
        </tr>
        <tr>
            <td class="layui-td-gray">开户行</td>
            <td>
                <input type="text" name="remit_account_bank" autocomplete="off"
                       lay-reqText="开户行" placeholder="开户行" class="layui-input">
            </td>
            <td class="layui-td-gray">户名</td>
            <td>
                <input type="text" name="remit_account_name" autocomplete="off"
                       lay-reqText="户名" placeholder="户名" class="layui-input">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">账号</td>
            <td>
                <input type="text" name="remit_account_no" autocomplete="off"
                       lay-reqText="账号" placeholder="账号" class="layui-input">
            </td>
            <td class="layui-td-gray">金额</td>
            <td>
                <input type="number" name="remit_account_money" autocomplete="off"
                       lay-reqText="金额" placeholder="金额" class="layui-input">
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray">日期</td>
            <td>
                <input type="text" name="remit_account_date" id="remit_account_date" autocomplete="off"
                       lay-reqText="日期" placeholder="日期" class="layui-input">
            </td>
            <!--<td class="layui-td-gray">打款状态</td>-->
            <!--<td>-->
                <!--<select name="remit_account_status">-->
                    <!--<option value="">请选择打款状态</option>-->
                    <!--<option value="0">未打款</option>-->
                    <!--<option value="1">已打款</option>-->
                <!--</select>-->
            <!--</td>-->
        </tr>
        <tr>
            <td class="layui-td-gray">手机号</td>
            <td>
                <input type="text" name="remit_account_mobile" autocomplete="off"
                       lay-reqText="手机号" placeholder="手机号" class="layui-input">
            </td>
        </tr>
        <tr>
            <td colspan="6"><strong>附件上传</strong></td>
        </tr>
        <tr>
            <td colspan="6"><strong>请将附件名称描述清楚</strong></td>
        </tr>

        <tr>
            <td class="layui-td-gray">
                <button type="button" class="layui-btn layui-btn-sm" id="uploadBtn"><i class="layui-icon"></i>附件上传
                </button>
            </td>
            <td colspan="5" style="line-height:inherit">
                <div class="layui-row" id="fileBox">
                    <input type="hidden" id="fileBoxInput" data-type="file" name="file_ids" value="">
                </div>
            </td>
        </tr>

        <tr>
            <td colspan="6">
                <textarea name="remark" placeholder="请输入备注信息" class="layui-textarea"></textarea>
            </td>
        </tr>
        {else/}
        <table class="layui-table layui-table-form">
            <tr>
                <td colspan="6"><strong>打款信息</strong></td>
            </tr>
            <tr>
                <td class="layui-td-gray">开户行</td>
                <td>
                    <input type="text" name="remit_account_bank" value="{$detail.remit_account_bank}" autocomplete="off"
                           lay-reqText="开户行" placeholder="开户行" class="layui-input">
                </td>
                <td class="layui-td-gray">户名</td>
                <td>
                    <input type="text" name="remit_account_name" value="{$detail.remit_account_name}" autocomplete="off"
                           lay-reqText="户名" placeholder="户名" class="layui-input">
                </td>
            </tr>
            <tr>
                <td class="layui-td-gray">账号</td>
                <td>
                    <input type="text" name="remit_account_no" value="{$detail.remit_account_no}" autocomplete="off"
                           lay-reqText="账号" placeholder="账号" class="layui-input">
                </td>
                <td class="layui-td-gray">金额</td>
                <td>
                    <input type="number" name="remit_account_money" value="{$detail.remit_account_money}" autocomplete="off"
                           lay-reqText="金额" placeholder="金额" class="layui-input">
                </td>
            </tr>
            <tr>
                <td class="layui-td-gray">日期</td>
                <td>
                    <input type="text" name="remit_account_date" value="{$detail.remit_account_date}" id="remit_account_date" autocomplete="off"
                           lay-reqText="日期" placeholder="日期" class="layui-input">
                </td>
                <!--<td class="layui-td-gray">打款状态</td>-->
                <!--<td>-->
                    <!--<select name="remit_account_status">-->
                        <!--<option value="" <?php if($detail['remit_account_status']==''){ echo 'selected';}?>>请选择打款状态</option>-->
                        <!--<option value="0" <?php if($detail['remit_account_status']=='0'){ echo 'selected';}?>>未打款</option>-->
                        <!--<option value="1" <?php if($detail['remit_account_status']=='1'){ echo 'selected';}?>>已打款</option>-->
                    <!--</select>-->
                <!--</td>-->
            </tr>
            <tr>
                <td class="layui-td-gray">手机号</td>
                <td>
                    <input type="text" name="remit_account_mobile" value="{$detail.remit_account_mobile}" autocomplete="off"
                           lay-reqText="手机号" placeholder="手机号" class="layui-input">
                </td>
            </tr>

            <tr>
                <td colspan="6"><strong>附件上传</strong></td>
            </tr>
            <tr>
                <td colspan="6"><strong>请将附件名称描述清楚（多附件格式）</strong></td>
            </tr>
            <tr>
                <td class="layui-td-gray">
                    <button type="button" class="layui-btn layui-btn-sm" id="uploadBtn"><i class="layui-icon"></i>附件上传
                    </button>
                </td>
                <td colspan="5" style="line-height:inherit">
                    <div class="layui-row" id="fileBox">
                        <input type="hidden" data-type="file" name="file_ids" value="{$detail.file_ids}">
                        {notempty name="$detail.file_ids"}
                        {volist name="$detail.fileArray" id="vo"}
                        <div class="layui-col-md4" id="uploadImg{$vo.id}">{:file_card($vo)}</div>
                        {/volist}
                        {/notempty}
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="6">
                    <textarea name="remark" placeholder="请输入备注信息" class="layui-textarea">{$detail.remark}</textarea>
                </td>
            </tr>
            {/if}
            <tr>
                <td class="layui-td-gray">审批流程<font>*</font></td>
                <td colspan="5">
                    <select name="flow_id" lay-verify="required" lay-filter="flowtype" lay-reqText="请选择审批流程">
                        <option value="">--请选择--</option>
                        {volist name="flows" id="vo"}
                        <option value="{$vo.id}" title="{$vo.check_type}">{$vo.name}</option>
                        {/volist}
                    </select>
                </td>
            </tr>
            <tr id="flow_tr">
                <td class="layui-td-gray">审核人<font>*</font></td>
                <td colspan="5">
                    <input type="hidden" name="check_admin_ids" value="" readonly><input type="text" name="check_admin_name" value="" autocomplete="off" placeholder="请选择审核人" lay-verify="required" lay-reqText="请选择审核人" class="layui-input" readonly>
                </td>
            </tr>
            <tr>
                <td class="layui-td-gray">抄送人</td>
                <td colspan="5">
                    <input type="text" name="copy_names" value="" autocomplete="off" placeholder="请选择审核人" class="layui-input picker-more" readonly><input type="hidden" name="copy_uids" value="" readonly>
                </td>
            </tr>
        </table>
        <div class="py-3">
            <input name="id" id="id" type="hidden" value="{$id}">
            <input name="transfer_id" id="transfer_id" type="hidden" value="{$transfer_id}">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool', 'employeepicker', 'oaTool'];

    function gouguInit() {
        var form = layui.form, tool = layui.tool, table = layui.table, laydate = layui.laydate, oaTool = layui.oaTool,
            employeepicker = layui.employeepicker;

        laydate.render({
            elem: '#remit_account_date',
            showBottom: false
        });

        //相关附件上传
        oaTool.addFile();
        //radio选择
        form.on('radio(tax)', function (data) {
            if (data.value == 0) {
                $('[name="tax"]').val('0').hide();
            } else {
                $('[name="tax"]').val('').show();
            }
        });

        //监听提交
        form.on('submit(webform)', function (data) {

            let callback = function (e) {
                layer.msg(e.msg);
                if (e.code == 0) {
                    tool.sideClose(1000);
                }
            }
            tool.post("/busine/businetransfer/payment_add", data.field, callback);
            return false;
        });

        form.on('select(flowtype)', function(data){
            var check_type = data.elem[data.elem.selectedIndex].title;
            var formHtml='<td class="layui-td-gray">审核人<font>*</font></td>\
		<td colspan="5">\
			<input type="text" name="check_admin_name" value="" autocomplete="off" placeholder="请选择审核人" lay-verify="required" lay-reqText="请选择审核人" class="layui-input picker-one"><input type="hidden" name="check_admin_ids" value="">\
		</td>';
            if(check_type == 2){
                $('#flow_tr').html(formHtml);
                form.render();
            }
            if(data.value==''){
                return false;
            }
            $.ajax({
                url: "/api/index/get_flow_users",
                type:'get',
                data:{id:data.value},
                success: function (e) {
                    if (e.code == 0) {
                        var flowLi='';
                        var flow_data = e.data.flow_data;
                        if(e.data.copy_uids && e.data.copy_uids !=''){
                            $('[name="copy_names"]').val(e.data.copy_unames);
                            $('[name="copy_uids"]').val(e.data.copy_uids.split(','));
                        }
                        if(check_type == 1 || check_type == 3){
                            for(var a=0;a<flow_data.length;a++){
                                var userList='',sign_type = '';
                                if(check_type == 1){
                                    if(flow_data[a].flow_type==1){
                                        userList+= '<li style="padding:3px 0">当前部门负责人</li>';
                                    }
                                    else if(flow_data[a].flow_type==2){
                                        userList+= '<li style="padding:3px 0">上级部门负责人</li>';
                                    }
                                    else{
                                        if(flow_data[a].flow_type==3){
                                            sign_type= ' <span class="layui-badge layui-bg-blue">或签</span>';
                                        }
                                        if(flow_data[a].flow_type==4){
                                            sign_type= ' <span class="layui-badge layui-bg-blue">会签</span>';
                                        }
                                        for(var b=0;b<flow_data[a].user_id_info.length;b++){
                                            userList+= '<li style="padding:3px 0"><img src="'+flow_data[a].user_id_info[b].thumb+'" style="width:24px; height:24px; border-radius:50%; margin-right:8px;" />'+flow_data[a].user_id_info[b].name+'</li>';
                                        }
                                    }
                                }
                                else if(check_type == 3){
                                    sign_type= ' <span class="layui-badge layui-bg-blue">'+flow_data[a].flow_name+'</span>'
                                    for(var b=0;b<flow_data[a].user_id_info.length;b++){
                                        userList+= '<li style="padding:3px 0"><img src="'+flow_data[a].user_id_info[b].thumb+'" style="width:24px; height:24px; border-radius:50%; margin-right:8px;" />'+flow_data[a].user_id_info[b].name+'</li>';
                                    }
                                }
                                flowLi+='<li class="layui-timeline-item">\
								<i class="layui-icon layui-timeline-axis">&#xe63f;</i>\
								<div class="layui-timeline-content">\
								  <p class="layui-timeline-title"><strong>第'+(a+1)+'级审批</strong>'+sign_type+'</p>\
								  <ul>'+userList+'</ul>\
								</div>\
							</li>';
                            }
                            formHtml = '<td class="layui-td-gray">审批流程</td>\
									<td colspan="7">\
										<ul id="flowList" class="layui-timeline">'+flowLi+'</ul>\
									</td>';
                            $('#flow_tr').html(formHtml);
                        }
                    }
                }
            })
        });
    }
</script>
{/block}
<!-- /脚本 -->